﻿@using Top.Api.Response;
@using HuiJiYunGo.EF;
@{
    ViewBag.Title = "好货精选 - 惠集云GO，优惠云集";
    Layout = "~/Views/Shared/_LayoutShow.cshtml";
    var ResultList = ViewBag.ResultList as List<TbkDgMaterialOptionalResponse.MapDataDomain>;
    //var CategoryList = ViewBag.CategoryList as List<CategoryLevelOneViewModel>;
    var MaterialIdList = ViewBag.MaterialIdList as List<ItemsDetail>;
}
<style>
    .title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }
</style>
<div class="commodity-content">
    <div class="commod-cont-wrap">
        <div class="commod-cont w1200 layui-clear">
            <div class="left-nav">
                <div class="title">分类</div>
                <div class="list-box">
                    @*@foreach (var item in MaterialIdList)
                        {
                            <dl>
                                <dt>@item.ItemName</dt>
                                @foreach (var item2 in item.CategoryList)
                                {
                                    <dd><a href="/NPN?Key=@ViewBag.Key&cat=@item2.al_id&Page=@ViewBag.Page&sort=@ViewBag.Sort">@item2.name</a></dd>
                                }
                            </dl>
                        }*@

                    <dl>
                        @*<dt>综合</dt>*@
                        @foreach (var item in MaterialIdList)
                        {
                            <dd><a href="/NPN?Key=@item.ItemName&mid=@item.ItemCode&Page=1&sort=@ViewBag.Sort">@item.ItemName</a></dd>
                        }
                    </dl>

                </div>
            </div>
            <div class="right-cont-wrap">
                <div class="right-cont">
                    <div class="sort layui-clear">
                        <a href="/NPN?Key=@ViewBag.Key&cat=@ViewBag.Cat&Page=@ViewBag.Page&sort=tk_total_sales_des" @(ViewBag.Sort == "tk_total_sales_des" ? "class=active" : "")>综合</a>
                        <a href="/NPN?Key=@ViewBag.Key&cat=@ViewBag.Cat&Page=@ViewBag.Page&sort=total_sales_des" @(ViewBag.Sort == "total_sales_des" ? "class=active" : "")>销量</a>
                        <a href="/NPN?Key=@ViewBag.Key&cat=@ViewBag.Cat&Page=@ViewBag.Page&sort=price_asc" @(ViewBag.Sort == "price_asc" ? "class=active" : "")>价格</a>
                    </div>
                    <div class="prod-number">
                        <span>@(ViewBag.TotalResults) 条</span>
                    </div>
                    <div class="buytoday-content">
                        <div class="cont-list layui-clear list-cont" id="list-cont">
                            @foreach (var item in ResultList)
                            {
                                @*<div class="item" onclick="window.location.href = '@item.CouponShareUrl'">
                                        <div class="img">
                                            <a href="javascript:;"><img src="@item.PictUrl" style="width:280px;height:280px;"></a>
                                        </div>
                                        <div class="text">
                                            <p class="title" style="width:270px;">@item.ShortTitle</p>
                                            <p class="price">
                                                <span class="pri">￥@item.ZkFinalPrice</span>
                                                <span class="discount">领券立减@(item.CouponAmount)元</span>
                                                <span class="nub" onclick="window.location.href = '@item.CouponShareUrl'" style="color:crimson;">￥@(decimal.Parse(item.ZkFinalPrice)- decimal.Parse(item.CouponAmount))</span>
                                            </p>
                                        </div>
                                    </div>*@
                                <div class="item" title="@item.Title">
                                    <img src="@item.PictUrl" alt="" style="width:280px;height:280px;">
                                    <div class="text-box">
                                        <p class="title">@(string.IsNullOrEmpty(item.ShortTitle)?item.Title:item.ShortTitle)</p>
                                        <p class="plic">
                                            <span class="ciur-pic" style="color:crimson;">￥@(decimal.Parse(item.ZkFinalPrice)- decimal.Parse(item.CouponAmount))</span>
                                            <span class="Ori-pic">￥@item.ZkFinalPrice</span>
                                            <span class="discount" onclick="window.location.href='@item.CouponShareUrl'" style="width:92px;"> 领取@(item.CouponAmount)元券</span>
                                        </p>
                                    </div>
                                </div>

                            }
                        </div>
                    </div>
                    <div id="demo0" style="text-align: center;"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
        layui.config({
            base: '../Content/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
        }).use(['mm', 'laypage', 'jquery','laytpl'], function () {
            var laypage = layui.laypage, $ = layui.$,
                mm = layui.mm;
            var laytpl = layui.laytpl;
            laypage.render({
                elem: 'demo0'
                , theme: '#f00582'
                , count: '@(ViewBag.TotalResults)' //数据总数
                , limit: 15
                , curr:'@ViewBag.Page'
                , jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    if (!first) {
                        window.location.href = "?mid=@(ViewBag.Mid)&page=" + obj.curr + "&key=@ViewBag.Key";
                    }
                }
            });

            $('.sort a').on('click', function () {
                $(this).addClass('active').siblings().removeClass('active');
            })
            $('.list-box dt').on('click', function () {
                if ($(this).attr('off')) {
                    $(this).removeClass('active').siblings('dd').show()
                    $(this).attr('off', '')
                } else {
                    $(this).addClass('active').siblings('dd').hide()
                    $(this).attr('off', true)
                }
            })

        });
</script>
